package com.android.example.app3;

import android.content.Context;
import android.util.Log;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class ClearFileExample {
    public static void clearFile(Context context, String lines) {
        // 获取应用专属外部存储目录
        File externalFilesDir = context.getExternalFilesDir(null);
        if (externalFilesDir != null) {
            File rulesFile = new File(externalFilesDir, "danhaoList.txt");
            // 将更新后的内容写回文件
            try (BufferedWriter writer = new BufferedWriter(new FileWriter(rulesFile))) {

                writer.flush();

            } catch (IOException e) {
                Log.e("ClearFileExample", "clearFile失败", e);
            }
        }
    }

}